/**
  **************************************************************************
  * @file     at32f403a_407_board.h
  * @version  v2.0.7
  * @date     2022-02-11
  * @brief    header file for at-start board. set of firmware functions to 
  *           manage leds and push-button. initialize delay function.
  **************************************************************************
  *                       Copyright notice & Disclaimer
  *
  * The software Board Support Package (BSP) that is made available to 
  * download from Artery official website is the copyrighted work of Artery. 
  * Artery authorizes customers to use, copy, and distribute the BSP 
  * software and its related documentation for the purpose of design and 
  * development in conjunction with Artery microcontrollers. Use of the 
  * software is governed by this copyright notice and the following disclaimer.
  *
  * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
  * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
  * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
  * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
  * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
  *
  **************************************************************************
  */

#ifndef __AT32F403A_407_BOARD_H
#define __AT32F403A_407_BOARD_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdio.h>
#include "at32f403a_407.h"

/** @addtogroup AT32F403A_407_board
  * @{
  */

/** @addtogroup BOARD
  * @{
  */

/** @defgroup BOARD_pins_definition 
  * @{
  */
#ifndef AT_START_F403A_V1
#define AT_START_F403A_V1
#endif

/**
  * this header include define support list:
  * 1. at-start-f403a v1.x board
  * 2. at-start-f407 v1.x board
  * if define AT_START_F403A_V1, the header file support at-start-f403a v1.x board
  * if define AT_START_F407_V1, the header file support at-start-f407 v1.x board
  */

#if !defined (AT_START_F403A_V1)&& !defined (AT_START_F407_V1)
#error "please select first the board at-start device used in your application (in at32f403a_407_board.h file)"
#endif


/**************** define print uart ******************/
#define PRINT_UART                       USART3
#define PRINT_UART_CRM_CLK               CRM_USART3_PERIPH_CLOCK
#define PRINT_UART_TX_PIN                GPIO_PINS_10
#define PRINT_UART_RX_PIN                GPIO_PINS_11
#define PRINT_UART_TX_GPIO               GPIOC
#define PRINT_UART_TX_GPIO_CRM_CLK       CRM_GPIOC_PERIPH_CLOCK

/******************** define led ********************/
#define BD_GPIO_RUNLED_PIN                   GPIO_PINS_11
#define BD_GPIO_RUNLED_PORT                  GPIOA
#define BD_GPIO_RUNLED_ON                    ((BD_GPIO_RUNLED_PORT->clr) = BD_GPIO_RUNLED_PIN)
#define BD_GPIO_RUNLED_OFF                   ((BD_GPIO_RUNLED_PORT->scr) = BD_GPIO_RUNLED_PIN)
#define BD_GPIO_RUNLED_XOR                  ((BD_GPIO_RUNLED_PORT->odt) ^= BD_GPIO_RUNLED_PIN)

/******************** define feed wtdd ********************/
#define BD_GPIO_WTDCLR_PIN                  GPIO_PINS_2
#define BD_GPIO_WTDCLR_PORT                 GPIOE
#define BD_GPIO_WTDCLR_XOR                  ((BD_GPIO_WTDCLR_PORT->odt) ^= BD_GPIO_WTDCLR_PIN)

// 应用串口的校验码(0无 1奇 2偶)
#define APP_UART_PARITY                     2

/******************** functions ********************/
void at32_board_init(void);

/* printf uart init function */
void uart_print_init(uint32_t baudrate, uint32_t parity);


void at32_WTD_Update(void);
void at32_WTD_Init(void);
void at32_led_init_1(void);
void at32_Runled_toggle(void);

/**
  * @}
  */

/**
  * @}
  */

/**
  * @}
  */

#ifdef __cplusplus
}
#endif

#endif

